package com.kwan.xframe.mvvm.data.source.http;


import com.chad.library.adapter.base.entity.MultiItemEntity;

import java.io.Serializable;

/**
 * 服务器 返回消息
 * Created by Mr.Kwan on 2016-6-28.
 */
public class HttpResult<T> implements IHttpResult<T>, Serializable, MultiItemEntity {

	private int code;
	private String message;
	private T data;

	private int resultCode;

	private String resultMsg;

	@Override
	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	@Override
	public String getMessage() {
		return message==null?resultMsg:message;
	}

	public void setMessage(String message) {
		this.message = message;
		this.resultMsg = message;
	}

	@Override
	public T getData() {
		return data;
	}

	@Override
	public int getTokenExpireCode() {
		return 5555;
	}

	@Override
	public boolean isSuccess() {
		return code == 0 || code == 200;
	}

	public void setData(T data) {
		this.data = data;
	}

	@Override
	public int getItemType() {
		return 0;
	}

	public int getResultCode() {
		return resultCode;
	}

	public void setResultCode(int resultCode) {
		this.resultCode = resultCode;
	}

	public String getResultMsg() {
		return resultMsg;
	}

	public void setResultMsg(String resultMsg) {
		this.resultMsg = resultMsg;
	}

	@Override
	public String toString() {
		return "HttpResult{" +
				"code=" + code +
				", message='" + message + '\'' +
				", data=" + data +
				'}';
	}
}
